﻿using System.Collections.Generic;
using System.Net;
using PhiStore.Policies;

namespace PhiStore.Interfaces
{
    internal interface IDataStore<TValue>
    {
        //Create
        string Create(TValue value, Policy policy);
        void Create(string key, TValue value, Policy policy);

        //Read
        TValue Read(string key);

        //Update
        void Update(string key, TValue value);

        //Delete
        void Delete(string key);

        /* List functions */
        //Create
        string ListCreate(IList<TValue> values, Policy policy);
        void ListCreate(string key, IList<TValue> values, Policy policy);

        //Read
        TValue ListRead(string key, long index);
        IList<TValue> ListRead(string key, long offset, long length);
        long ListCount(string key);

        //Update
        void ListUpdate(string key, TValue value, long index);
        void ListUpdate(string key, IList<TValue> values, long offset);
        void ListAppend(string key, TValue value);
        void ListAppend(string key, IList<TValue> values);
        TValue ListPop(string key);

        //Delete
        void ListDelete(string key, long index);
        void ListDelete(string key, long offset, long length);

        //Initialize connection
        void Initialize();
        void Initialize(bool compress);
        void Initialize(string encryptionKey);
        void Initialize(bool compress, string encryptionKey);

        void Connect(IPAddress ip, int port);
        void Connect();
    }
}
